package linkedList;

public class Solution3 {
    public ListNode removeElements(ListNode head, int val){
      if(head == null){
          return null;
      }
      head.next = removeElements(head.next,val);
     return head.val == val ? head.next : head;

    }

    public static void main(String[] args) {
        int[] arr = {1,2,6,3,4,6,6};
        ListNode head = new ListNode(arr);
        System.out.println(head);
        Solution3 solution = new Solution3();
        ListNode res  = solution.removeElements(head,6);
        System.out.println(res);
    }
}
